﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Heritage.Logging
{
    public class LogService
    {
        private const string DEBUG = "DEBUG";
        private const string VERBOSE = "VERBOSE";
        private const string INFO = "INFO";
        private const string WARN = "WARN";
        private const string ERROR = "ERROR";
        private const string FATAL = "FATAL";

        private static void Log(string level, string principal, string component, string message) 
        {
            LEnts ents = new LEnts();
            LogTable entry = LogTable.CreateLogTable(1, DateTime.Now, level, message);
            entry.Component = component;
            entry.Principal = principal;
            ents.AddToLogTables(entry);
            ents.SaveChanges();
        }

        public static void Info(string principal, string component, string message)
        {
            Log(INFO, principal, component, message);
        }
        public static void Debug(string principal, string component, string message)
        {
            Log(DEBUG, principal, component, message);
        }
        public static void Verbose(string principal, string component, string message)
        {
            Log(VERBOSE, principal, component, message);
        }
        public static void Warn(string principal, string component, string message)
        {
            Log(WARN, principal, component, message);
        }
        public static void Error(string principal, string component, string message)
        {
            Log(ERROR, principal, component, message);
        }
        public static void Fatal(string principal, string component, string message)
        {
            Log(FATAL, principal, component, message);
        }
    }
}
